#pragma once

#include <vector>

namespace jianzhi_039
{

class Solution
{
public:
    int majorityElement(const std::vector<int>& nums)
    {
        int votes = 1;
        int major = nums.front();
        for (int i = 1; i < (int)nums.size(); ++i) {
            if (votes == 0)
                major = nums.at(i);
            votes += (nums.at(i) == major) ? 1 : -1;
        }
        return major;
    }
};

}  /* namespace jianzhi_039 */
